from abc import ABC, abstractmethod
from concurrent.futures import Future
from logging import WARNING
from typing import List

from utils.LogDecorator import LogDecorator


class ExecutorInterface(ABC):
    log = LogDecorator(name=__name__, level=WARNING)

    @abstractmethod
    def run_command(self, command: List[str]) -> str:
        """同步执行命令"""
        pass

    @abstractmethod
    async def async_run_command(self, command: List[str]) -> str:
        """异步执行命令"""
        pass

    @abstractmethod
    def run_in_thread(self, command: List[str]) -> "Future[str]":
        """
        在线程中运行命令（多线程执行）

        Args:
            command: 要执行的命令列表
            
        Returns:
            Future[str]: 可以通过result()方法获取执行结果的Future对象
        """
        pass

    @abstractmethod
    def terminate_process(self) -> None:
        """终止进程并标记为手动终止
        
        Note:
            此方法会强制终止当前运行的命令进程
        """
        pass

    def __str__(self) -> str:
        """获取工具名称"""
        return self.__class__.__name__
